#!/bin/bash
cp /opt/Oyun/editor/OyunMnEditor.desktop /usr/share/applications
sudo chmod 0644 /usr/share/applications/OyunMnEditor.desktop
cp /opt/Oyun/editor/OyunMnEditorIco.png /usr/share/pixmaps
sudo chmod 0644 /usr/share/pixmaps/OyunMnEditorIco.png

sysUsers="`cat /etc/passwd | awk -F: '$3>=1000'| cut -f 1 -d : | grep -v 'nobody'`"
#echo $sysUsers
usersArr=($sysUsers)
for((i=0;i<${#usersArr};i++))
do
 desktop="$(sudo -u ${usersArr[i]} xdg-user-dir DESKTOP 2>/dev/null)"
 if [ -n "$desktop" ]; then
   #echo "${usersArr[i]}:$desktop"
   sudo cp /opt/Oyun/editor/OyunMnEditor.desktop "$desktop"
   sudo chmod 0755 "$desktop"/OyunMnEditor.desktop
   sudo chown "${usersArr[i]}":root "$desktop"/OyunMnEditor.desktop
 fi
done
